
import {canvas,ctx} from './canvas'
export default class Letters {
    constructor(){
        this.x=Math.floor(Math.random()*400)+80
		this.y=50
		this.Ax=this.x-15
		this.Ay=this.y-40
		this.aLive=true
		this.speed=Math.random()*0.017+2
		this.lett=this.letters()[Math.floor(Math.random()*48)]
		this.lePic=new Image()
        this.lePic.src='./images/苹果[图形].png'
        this.ctx = ctx;
		this.fColor='yellow'
    }
    init(){
        this.leBackground();
    }
    letters(){
        return ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    }
    leBackground() {
        this.Ay+=this.speed;
        this.y+=this.speed;
        if(this.aLive){
            this.ctx.save();
            this.ctx.drawImage(this.lePic,this.Ax,this.Ay,55,55);
            this.ctx.font = "40px Courier New";
            this.ctx.fillStyle =''+this.fColor+'';
            this.ctx.fillText(this.lett, this.x, this.y);
            this.ctx.restore();
        }
    }
    
}

